﻿@model IEnumerable<HdipCricketClub.Models.Member>

@{
    ViewBag.Title = "Index";
}

<h2>Members:</h2>

<p>
    @Html.ActionLink("Add a New Member", "Create")
</p>

@using (Html.BeginForm())
{
    <p>
        Find by Last Name: @Html.TextBox("SearchString")
        <input type="submit" value="Search" />
    </p>
}

<table>
    <tr>
        <th>
            Name:
        </th>
        <th>
            Address:
        </th>
        <th>
            Mobile No:
        </th>
        <th>
            Phone No:
        </th>
        <th>
            E Mail:
        </th>
        <th>
            Playing Member:
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.first_name)
            @Html.DisplayFor(modelItem => item.last_name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.address_1),
            @if (item.address_2 != null)
            {       
                @Html.DisplayFor(modelItem => item.address_2)@:,  
            }
            @Html.DisplayFor(modelItem => item.town_city),
            @Html.DisplayFor(modelItem => item.County1.name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.mobile)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.phone)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.playing_member)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.member_id }) |
            @Html.ActionLink("Details", "Details", new { id=item.member_id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.member_id })
        </td>
    </tr>
}

</table>
